#include "main.h"
#include "ManKey.h"

ManKey manKey(0);

static ManKeyOutEvent * s_manKeyOutEvent;

void manKeyEventFilter(uint32_t ms, ManKeyEventCode manKeyEventCode){
    uint8_t evtCode=  manKeyEventCode.one.evtCode;

    Serial.printf("WWWWWW %d",evtCode);

    switch (evtCode)
    {
        case MAN_KEY_EVT_DOWN:
        {
            break;
        }
        case MAN_KEY_EVT_UP: {
            break;
        }
        case MAN_KEY_EVT_CLICK: {
            break;
        }
        case MAN_KEY_EVT_DBL_CLICK: {
            break;
        }
        case MAN_KEY_EVT_PRESSING:  {
            break;
        }
        case MAN_KEY_EVT_LONG_CLICK:  {
            break;
        }
    }
    if(s_manKeyOutEvent!=NULL && evtCode==MAN_KEY_EVT_LONG_CLICK){
        s_manKeyOutEvent(ms,manKeyEventCode);

    }
}




int manKeyDigitalRead(uint8_t inx){
   int val=  !digitalRead(13);
    return val;
}


void bspKeySetCallBack(ManKeyOutEvent* manKeyOutEvent){
    s_manKeyOutEvent=manKeyOutEvent;
}


void bspKeyInit(){
    pinMode(13, INPUT_PULLUP);
    ManKey::digitalRead=manKeyDigitalRead;
    ManKey::onEvent=manKeyEventFilter;
}





